<template>
  <div>
    <button @click="isShow = !isShow">显示/隐藏</button>

    <transition name="huazai">
      <div class="box" v-show="isShow"></div>
    </transition>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      isShow: true,
    };
  },
};
</script>

<style scoped>
.box {
  width: 300px;
  height: 300px;
  background-color: skyblue;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  50% {
    transform: translateX(111px);
  }
  to {
    opacity: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(111px);
  }

  to {
    opacity: 1;
  }
}

.huazai-leave-active {
  animation: fadeOut 2s linear;
}
.huazai-enter-active {
  animation: fadeIn 2s linear;
}
</style>